class Animal:
    def __init__(self, name, age=1):
        self.name  = name
        self.age = age

    def eat(self):
        print(f'{self}在吃饭')

    def play(self):
        print(f'{self}在玩')

    def sleep(self):
        print(f'{self}在睡觉')

class Dog(Animal):
    def work(self):
        print(f'{self}在看家')

    def __str__(self):
        return f'名字是{self.name},年龄是{self.age}的小狗'

class Cat(Animal):
    def work(self):
        print(f'{self}在捉老鼠')

    def __str__(self):
        return f'名字是{self.name},年龄是{self.age}的小猫'

class Person(Animal):
    def __init__(self, name, pets, age=1):
        super().__init__(name,age)
        self.pets = pets

    def yangPets(self):
        for pet in self.pets:
            pet.eat()
            pet.play()
            pet.sleep()

    def make_pets_work(self):
        for pet in self.pets:
            pet.work()

    def __str__(self):
        return f'名字是{self.name},年龄是{self.age}的人'
    
d = Dog('xiaohei', 1)
c = Cat('xiaobai', 11)
p = Person('wyl350', [d,c], 44)
print(p)
print('----')
# 
p.yangPets()
p.make_pets_work()
# 
